//导入request.js请求工具
import instance from '@/utils/request.js'
//提供调用用户名登录的接口函数
export const userLoginByNameService = (LoginDataByName)=>{
    return instance.post('/token/username',LoginDataByName);
}
//提供调用手机号登录的接口函数
export const userLoginByPhoneService = (LoginByPhoneData)=>{
    return instance.put('/token/phone',LoginByPhoneData);
}
//发送手机验证码
export const sendPhoneCodeLoginService = (phoneNumber)=>{
    return instance.put(`/loginPhoneCode/${phoneNumber}`);
}
export const sendPhoneCodeRegisterService = (phoneNumber)=>{
    return instance.put(`/registerCode/${phoneNumber}`);
}
export const sendPhoneCodeResetService = (phoneNumber)=>{
    return instance.put(`/resetPhoneCode/${phoneNumber}`);
}
//提供gitee登录
export const userLoginByGitee = (code)=>{
    let url = '/token/gitee/' + code
    return instance.get(url);
}
//提供调用手机号登注册的接口函数
export const userRegisterByPhoneService = (RegisterData)=>{
    return instance.put('/users/phone',RegisterData);
}
//判断第三方是否被注册
export const isGitee = (code) =>{
    let url = '/user/gitee/' + code
    return instance.get(url);
}
//第三方注册
export const userRegisterByGiteeService = (giteeRegisterData)=>{
    return instance.put('/users/gitee',giteeRegisterData)
}
//重置密码
export const resetPasswordService = (ResetPasswordData)=>{
    return instance.post('/resetPassword',ResetPasswordData);
}
//获取用户个人信息
export const getUserInfoService = (token)=>{
    return instance.get('/userInfos',token);
    // return fetch(`http://localhost:8080/userInfos/${token}`,{
    //     method:'GET'
    // }).then(response=>{
    //     if(response.status === 200){
    //         return response.json();
    //     } else {
    //         throw new Error('User information not found');
    //     }
    // }).then(data=>{
    //     console.log(data);
    //     return data;
    // }).catch(err=>{
    //     console.log(err);
    //     return {}; // 或者根据需要返回其他的空值
    // })
}

//保存用户信息
export const changeUserInfoService = (userInfoData)=>{
    return instance.post('/userInfos',userInfoData);
}
//获取用户聊天信息
export const getChatInfoService = (token)=>{
    return instance.get('/messages',token);
}
//关闭聊天框
export const closrChat = (token) =>{
    return instance.post('/closeChat',token);
}

export const myOrders=()=>{
    return instance.get('/orders');
}
// export const getUserInfoService=()=>{
//     return instance.get('/userInfos');
// }
//获取未付款订单
export const getNoPayOrdersService=()=>{
    return instance.get('/noPayOrders');
}

//获取已发货订单
export const getShipOrdersService=()=>{
    return instance.get('/shipOrders')
}

// 获取未发货订单
export const getNoShipOrdersService=()=>{
    return instance.get('/noShipOrders');
}

//获取未收到货的订单
export const getNoGetOrdersService=()=>{
    return instance.get('/noGetOrders');
}
